<template>
  <div class="home-container">
    <!-- 主要内容区域 -->
    <main class="main-content">
      <!-- 英雄区域 -->
      <section class="hero-section">
        <div class="hero-content">
          <h1 class="animate__animated animate__fadeInDown">传承国粹 弘扬文化</h1>
          <p class="animate__animated animate__fadeInUp animate__delay-1s">探索中国传统戏曲艺术的魅力</p>
          <button @click="showModuleSelectionDialog" class="cta-button animate__animated animate__fadeInUp animate__delay-2s">立即探索</button>
        </div>
        <div class="hero-overlay"></div>
      </section>

      <!-- 公告区域 -->
      <section class="announcements-section">
        <h2 class="section-title">最新公告</h2>
        <div class="announcements-container">
          <div v-if="announcements && announcements.length > 0" class="announcements-cards">
            <div 
              v-for="(announcement, index) in announcements" 
              :key="index" 
              class="announcement-card"
              @click="showAnnouncementDetail(announcement)"
            >
              <div class="announcement-card-content">
                <div class="announcement-icon">
                  <i class="el-icon-bell"></i>
                </div>
                <div class="announcement-title">{{ announcement.title || '未命名公告' }}</div>
                <div class="announcement-date">{{ formatAnnouncementDate(announcement.updateTime) }}</div>
                <div class="announcement-arrow">
                  <i class="el-icon-arrow-right"></i>
                </div>
              </div>
            </div>
          </div>
          <div v-else-if="announcementsLoading" class="announcements-loading">
            <div v-for="i in 3" :key="i" class="skeleton-announcement-card">
              <div class="skeleton-announcement-content">
                <div class="skeleton-icon"></div>
                <div class="skeleton-title"></div>
                <div class="skeleton-date"></div>
              </div>
            </div>
          </div>
          <div v-else class="no-announcements">
            <p>暂无公告信息</p>
          </div>
          <div class="announcements-more">
            <router-link to="/announcements" class="modern-btn">查看更多</router-link>
          </div>
        </div>
      </section>

      <!-- 京剧发展历史线 -->
      <section class="history-timeline-section">
        <h2 class="section-title">京剧发展历程</h2>
        <div class="timeline-horizontal">
          <div class="timeline-item-horizontal" v-for="(item, index) in timelineData" :key="index">
            <div class="timeline-point-horizontal"></div>
            <div class="timeline-content-horizontal">
              <h3>{{ item.year }}</h3>
              <p>{{ item.description }}</p>
            </div>
          </div>
        </div>
        <div class="timeline-more">
          <router-link to="/history" class="modern-btn">查看完整历史</router-link>
        </div>
      </section>

      <!-- 最新演出区域 -->
      <section class="shows-section">
        <h2 class="section-title">最新演出</h2>
        <div class="shows-grid" v-if="latestShows && latestShows.length > 0">
          <el-col :xs="24" :sm="24" :md="12" :lg="8" v-for="show in latestShows" :key="show.showId" class="show-card-col">
            <el-card class="show-card" :body-style="{ padding: '0px' }" shadow="hover">
              <div class="show-content">
                <div class="show-poster">
                  <img :src="show.posterUrl || require('@/assets/opera_bg1.jpg')" alt="演出海报" loading="lazy">
                  <div class="show-type">
                    <el-tag :type="getTagType(show.showType)">{{ show.showType }}</el-tag>
                  </div>
                </div>
                <div class="show-info">
                  <h3 class="show-name">{{ show.showName }}</h3>
                  <p class="show-time"><i class="el-icon-time"></i> {{ formatShowTime(show.showTime) }}</p>
                  <p class="show-address"><i class="el-icon-location"></i> {{ show.showAddress || '地点待定' }}</p>
                  <div class="show-action">
                    <el-button type="primary" @click="viewShowDetail(show)" round>查看详情</el-button>
                  </div>
                </div>
              </div>
            </el-card>
          </el-col>
        </div>
        <div v-else-if="loading" class="shows-loading">
          <div class="skeleton-container">
            <div v-for="i in 3" :key="i" class="skeleton-card">
              <div class="skeleton-image"></div>
              <div class="skeleton-content">
                <div class="skeleton-title"></div>
                <div class="skeleton-text"></div>
                <div class="skeleton-text"></div>
                <div class="skeleton-button"></div>
              </div>
            </div>
          </div>
        </div>
        <div v-else class="no-shows">
          <p>暂无演出信息</p>
        </div>
        <div class="shows-more">
          <router-link to="/shows" class="modern-btn">更多演出</router-link>
        </div>
      </section>
    </main>

    <!-- 长时间未登录提示框 -->
    <transition name="fade">
      <div class="modal" v-if="showModal">
        <div class="modal-content">
          <p>您已长时间未操作，请重新登录！</p>
          <button @click="confirmLogout" class="confirm-button">确定</button>
        </div>
      </div>
    </transition>

    <!-- 公告详情对话框 -->
    <el-dialog
      :title="currentAnnouncement.title || '公告详情'"
      :visible.sync="dialogVisible"
      width="50%"
      :before-close="handleDialogClose"
    >
      <div class="announcement-dialog-content">
        <div v-if="currentAnnouncement.loading" class="announcement-loading">
          <div class="announcement-loading-spinner">
            <i class="el-icon-loading"></i>
          </div>
          <div class="announcement-loading-text">加载中...</div>
        </div>
        
        <template v-else>
          <div class="announcement-dialog-date">
            <i class="el-icon-date"></i> {{ formatAnnouncementDate(currentAnnouncement.updateTime) }}
          </div>
          <div class="announcement-dialog-body" v-if="currentAnnouncement.content" v-html="currentAnnouncement.content"></div>
          <div class="announcement-dialog-body" v-else>暂无内容</div>
          
        </template>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">关闭</el-button>
      </span>
    </el-dialog>

    <!-- 模块选择对话框 -->
    <el-dialog
      title="探索京剧艺术"
      :visible.sync="moduleSelectionVisible"
      width="70%"
      :before-close="handleModuleDialogClose"
      custom-class="module-selection-dialog"
    >
      <div class="module-selection-content">
        <p class="module-selection-tip">选择感兴趣的模块，开启您的京剧文化之旅</p>
        
        <div class="module-grid">
          <div 
            v-for="module in availableModules" 
            :key="module.id" 
            class="module-item"
            @click="navigateToModule(module)"
          >
            <div class="module-content">
              <div class="module-icon">{{ module.icon }}</div>
              <div class="module-info">
                <div class="module-title">{{ module.name }}</div>
                <div class="module-description">{{ module.description }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="moduleSelectionVisible = false">关闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import service from '@/utils/request';

// 添加防抖函数工具
function debounce(fn, delay) {
  let timer = null;
  return function() {
    const context = this;
    const args = arguments;
    if (timer) clearTimeout(timer);
    timer = setTimeout(() => {
      fn.apply(context, args);
    }, delay);
  };
}

export default {
  name: 'HomeVue',
  data() {
    return {
      announcements: [],
      announcementsLoading: true,
      timelineData: [
        {
          year: '1790年',
          description: '京剧形成初期，四大徽班进京'
        },
        {
          year: '1840年',
          description: '三庆班成立，京剧艺术逐渐成熟'
        },
        {
          year: '1920年',
          description: '梅兰芳等京剧大师崛起，形成流派'
        },
        {
          year: '1950年',
          description: '京剧现代化改革，创新剧目涌现'
        },
        {
          year: '2000年至今',
          description: '京剧艺术创新发展，走向国际舞台'
        }
      ],
      latestShows: [],
      showModal: false,
      activityTimer: null,
      observer: null,
      loading: true,
      eventListeners: {},
      dialogVisible: false,
      currentAnnouncement: {},
      // 模块选择相关数据
      moduleSelectionVisible: false,
      availableModules: [
        {
          id: 'history',
          name: '京剧历史',
          icon: '📜',
          description: '了解京剧从形成到发展的历史演变过程',
          path: '/history'
        },
        {
          id: 'masters',
          name: '艺术大师',
          icon: '👑',
          description: '认识京剧历史上的代表性艺术家',
          path: '/artists'
        },
        {
          id: 'categories',
          name: '行当',
          icon: '🎭',
          description: '探索生旦净丑四大行当及其代表人物',
          path: '/categories'
        },
        {
          id: 'schools',
          name: '流派',
          icon: '👥',
          description: '探索京剧流派及其代表人物',
          path: '/schools'
        },
        {
          id: 'classics',
          name: '经典剧目',
          icon: '📚',
          description: '经典京剧剧目赏析与介绍',
          path: '/classics'
        },
        {
          id: 'techniques',
          name: '知识',
          icon: '🎯',
          description: '了解京剧唱念做打的基本功与技巧等知识',
          path: '/knowledge'
        },
        {
          id: 'shows',
          name: '演出',
          icon: '📢',
          description: '最新京剧演出活动信息公布',
          path: '/shows'
        },
        {
          id: 'guestbook',
          name: '留言',
          icon: '✉️',
          description: '建议与反馈',
          path: '/contact'
        },
        {
          id: 'forum',
          name: '论坛',
          icon: '💬',
          description: '京剧爱好者讨论交流平台',
          path: '/forum'
        }
      ]
    }
  },
  mounted() {
    document.title = '京剧苑 - 首页'
    window.scrollTo(0, 0);
    this.validateToken()
    this.checkUserActivity()
    this.initializeIntersectionObserver()
    this.fetchLatestShows()
    this.fetchAnnouncements()
    
    // 延迟执行token验证，确保其他任务先完成
    // setTimeout(() => {
    //   this.validateToken()
    // }, 100)
  },
  beforeDestroy() {
    // 清理定时器
    if (this.activityTimer) {
      clearTimeout(this.activityTimer);
    }
    
    // 使用存储的引用移除事件监听器
    if (this.eventListeners.debouncedReset) {
      window.removeEventListener('mousemove', this.eventListeners.debouncedReset);
      window.removeEventListener('keydown', this.eventListeners.debouncedReset);
      window.removeEventListener('touchstart', this.eventListeners.debouncedReset);
      window.removeEventListener('click', this.eventListeners.debouncedReset);
    }
    
    // 清理Intersection Observer
    if (this.observer) {
      this.observer.disconnect();
    }
  },
  methods: {
    validateToken() {
      const token = localStorage.getItem('token');
      if (!token) {
        return;
      }
      
      service.get('/api/system/user/validateToken', {
        params: { token }
      })
        .then(res => {
          if(res.code === 200) {
            // 更新token
            localStorage.removeItem('token');
            localStorage.setItem('token', res.data);
          } else {
            
            
            // 清除所有本地存储的用户信息
            ['token', 'screenName', 'avatar', 'roletype'].forEach(item => 
              localStorage.removeItem(item)
            );
            
            // 清除组件中的用户信息
            if (this.screenName !== undefined) this.screenName = '';
            if (this.avatar !== undefined) this.avatar = '';
            if (this.dropdownVisible !== undefined) this.dropdownVisible = false;
            if (typeof this.closeMobileMenu === 'function') this.closeMobileMenu();
            
            this.$message({
              type: 'error',
              message: '登录过期，请重新登录!'
            });
            // 重定向到登录页
            this.$router.push('/login');
          }
        })
        .catch(() => {
          // 错误处理
        });
    },
    // 获取最新的六个演出
    fetchLatestShows() {
      this.loading = true;
      service.get('/api/content/show/getShows')
        .then(res => {
          if (res.code === 200) {
            if (Array.isArray(res.data)) {
              // 过滤掉已过期的演出
              const currentTime = new Date();
              const validShows = res.data.filter(show => new Date(show.showTime) > currentTime);
              
              // 按照showTime字段降序排序（最新的在前）
              const sortedShows = validShows.sort((a, b) => {
                return new Date(b.showTime) - new Date(a.showTime);
              });
              
              // 获取排序后的前六个（或全部，如果少于六个）
              this.latestShows = sortedShows.slice(0, 6);
            } else {
              this.latestShows = [];
            }
          } else {
            this.latestShows = [];
          }
        })
        .catch(() => {
          this.latestShows = [];
        })
        .finally(() => {
          this.loading = false;
        });
    },

    checkUserActivity() {
      // 设置无活动超时时间为3分钟
      const inactivityTimeout = 180000;
      
      const alertUser = () => {
        this.showModal = true;
      }
      
      this.activityTimer = setTimeout(alertUser, inactivityTimeout);
      
      // 使用防抖函数减少事件处理次数
      this.eventListeners.debouncedReset = debounce(() => {
        this.resetActivityTimer(inactivityTimeout);
      }, 300);
      
      window.addEventListener('mousemove', this.eventListeners.debouncedReset);
      window.addEventListener('keydown', this.eventListeners.debouncedReset);
      window.addEventListener('touchstart', this.eventListeners.debouncedReset);
      window.addEventListener('click', this.eventListeners.debouncedReset);
    },
    
    resetActivityTimer(timeout = 180000) {
      clearTimeout(this.activityTimer);
      this.activityTimer = setTimeout(() => {
        this.showModal = true;
      }, timeout);
    },
    confirmLogout() {
      this.showModal = false;
      
      // 使用数组批量删除localStorage条目
      ['token', 'screenName', 'avatar', 'roletype'].forEach(item => 
        localStorage.removeItem(item)
      );
      
      // 重定向到登录页
      this.$router.push('/login');
    },
    initializeIntersectionObserver() {
      // 创建观察者实例
      this.observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
          if (entry.isIntersecting) {
            // 添加动画类
            entry.target.classList.add('animate__animated', 'animate__fadeIn');
            
            // 可选：元素显示后停止观察
            // this.observer.unobserve(entry.target);
          }
        });
      }, {
        threshold: 0.1,
        rootMargin: '0px 0px 50px 0px' // 提前开始动画
      });

      // 选择需要观察的元素
      const elementsToObserve = document.querySelectorAll(
        '.timeline-item-horizontal, .show-card-col, .announcement-item'
      );
      
      // 注册所有元素
      elementsToObserve.forEach(el => {
        this.observer.observe(el);
      });
    },
    // 格式化显示时间
    formatShowTime(timeString) {
      if (!timeString) return '待定';
      try {
        const date = new Date(timeString);
        if (isNaN(date.getTime())) return '待定';
        
        const year = date.getFullYear();
        const month = date.getMonth() + 1;
        const day = date.getDate();
        const hours = date.getHours();
        const minutes = date.getMinutes();
        
        return `${year}年${month}月${day}日 ${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
      } catch (error) {
        return '待定';
      }
    },
    
    // 查看艺术家详情
    viewArtistDetail(artist) {
      this.$router.push({
        name: 'ArtistDetail',
        params: { id: artist.id }
      });
    },
    
    // 获取标签类型
    getTagType(showType) {
      const typeMap = {
        '商业': 'success',
        '公益': 'info',
        '文化交流': 'warning',
        '其他': 'primary'
      };
      return typeMap[showType] || 'primary';
    },
    
    // 查看演出详情
    viewShowDetail(show) {
      this.$router.push({
        name: 'ShowDetail',
        params: { id: show.showId }
      });
    },
    // 获取最新公告
    fetchAnnouncements() {
      this.announcementsLoading = true;
      service.get('/api/system/announcement/getAnnouncements')
        .then(res => {
          if (res.code === 200) {
            if (Array.isArray(res.data)) {
              // 按照updateTime字段降序排序（最新的在前）
              const sortedAnnouncements = res.data.sort((a, b) => {
                return new Date(b.updateTime) - new Date(a.updateTime);
              });
              
              // 获取排序后的前五个（或全部，如果少于五个）
              const announcements = sortedAnnouncements.slice(0, 5);
              
              // 添加showDetails属性，用于控制详情的显示和隐藏
              announcements.forEach(item => {
                item.showDetails = false;
              });
              
              this.announcements = announcements;
            } else {
              this.announcements = [];
            }
          } else {
            this.announcements = [];
          }
        })
        .catch(() => {
          this.announcements = [];
        })
        .finally(() => {
          this.announcementsLoading = false;
        });
    },
    
// 格式化公告日期
formatAnnouncementDate(dateString) {
  if (!dateString) return '未知时间';
  
  try {
    const date = new Date(dateString);
    // 检查日期是否有效
    if (isNaN(date.getTime())) {
      return '未知时间';
    }
    
    const year = date.getFullYear();
    const month = date.getMonth() + 1;
    const day = date.getDate();
    const hours = date.getHours();
    const minutes = date.getMinutes();
    const seconds = date.getSeconds();
    
    return `${year}年${month}月${day}日 ${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
  } catch (error) {
    return '未知时间';
  }
},
    
    
    // 显示公告详情对话框
    showAnnouncementDetail(announcement) {
      this.currentAnnouncement = { ...announcement, loading: true };
      this.dialogVisible = true;
      
      this.currentAnnouncement = { ...announcement, loading: false };
    },
    
    // 关闭对话框
    handleDialogClose(done) {
      // 复位当前公告对象
      setTimeout(() => {
        this.currentAnnouncement = {};
      }, 300);
      done();
    },

    // 显示模块选择对话框
    showModuleSelectionDialog() {
      this.moduleSelectionVisible = true;
    },
    
    // 处理模块选择对话框关闭
    handleModuleDialogClose(done) {
      done();
    },
    
    // 导航到模块
    navigateToModule(module) {
      this.$router.push(module.path);
      this.moduleSelectionVisible = false;
    },
  }
}
</script>

<style scoped>
/* 全局样式 */
.home-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden; /* 防止水平滚动 */
}

/* 主要内容区域样式 */
.main-content {
  flex: 1;
}

/* 英雄区域样式 */
.hero-section {
  height: 80vh;
  background: url('@/assets/opera_bg1.jpg') center/cover no-repeat;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  overflow: hidden;
  background-attachment: fixed;
  will-change: transform; /* 性能优化 */
}

.hero-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(139, 0, 0, 0.8), rgba(0, 0, 0, 0.85));
  z-index: 1;
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 800px;
  padding: 0 20px;
  will-change: transform, opacity; /* 性能优化 */
}

.hero-content h1 {
  font-size: 4.5rem;
  font-family: 'STXingkai', 'STZhongsong', 'SimSun', serif;
  margin-bottom: 1.5rem;
  color: transparent;
  text-shadow: none;
  background: linear-gradient(to right, #FFD700, #FFA500);
  -webkit-background-clip: text;
  background-clip: text;
  line-height: 1.2;
}

.hero-content p {
  font-size: 1.8rem;
  margin-bottom: 2.5rem;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.cta-button {
  display: inline-block;
  padding: 1.2rem 3rem;
  background: #FFD700;
  color: #8B0000;
  text-decoration: none;
  border-radius: 50px;
  font-size: 1.3rem;
  font-weight: bold;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94); /* 平滑过渡 */
  box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.cta-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
  background: #FFE55C;
}

/* 性能优化 - 减少重绘和重排 */
.artist-card, .announcement-item, .timeline-item-horizontal, .show-card {
  will-change: transform, opacity;
  transform: translateZ(0);
}

/* 全局动画优化 */
@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

/* 移动端优化 */
@media (max-width: 768px) {
  .hero-section {
    background-attachment: scroll; /* 移动设备上禁用fixed以提高性能 */
  }
  
  .artist-card {
    animation: none !important; /* 移动设备上禁用浮动动画以提高性能 */
  }
}

/* 公告区域样式 */
.announcements-section {
  padding: 6rem 10%;
  background: #fff;
}

.announcements-container {
  max-width: 1200px;
  margin: 0 auto;
}

.announcements-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.announcement-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.announcement-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  background-color: #f9f9f9;
}

.announcement-card-content {
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
}

.announcement-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(139, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 1rem;
}

.announcement-icon i {
  color: #8B0000;
  font-size: 1.2rem;
}

.announcement-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 0;
  padding-right: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.announcement-date {
  color: #909399;
  font-size: 0.85rem;
  white-space: nowrap;
  margin-left: auto;
  padding-right: 2rem;
}

.announcement-arrow {
  position: absolute;
  right: 1.5rem;
  color: #c0c4cc;
  transition: all 0.3s ease;
}

.announcement-card:hover .announcement-arrow {
  color: #8B0000;
  transform: translateX(3px);
}

/* 公告加载样式 */
.announcements-loading {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.skeleton-announcement-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  padding: 0;
}

.skeleton-announcement-content {
  display: flex;
  align-items: center;
  padding: 1rem 1.5rem;
}

.skeleton-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #e0e0e0;
  margin-right: 1rem;
  flex-shrink: 0;
}

.skeleton-title {
  width: 50%;
  height: 20px;
  background-color: #e0e0e0;
  border-radius: 4px;
  margin-right: 1rem;
  margin-bottom: 0;
}

.skeleton-date {
  width: 20%;
  height: 16px;
  background-color: #e0e0e0;
  border-radius: 4px;
  margin-left: auto;
}

.no-announcements {
  text-align: center;
  padding: 2.5rem;
  background: #f9f9f9;
  border-radius: 10px;
  font-size: 1.1rem;
  color: #666;
  margin-bottom: 2rem;
}

.announcements-more {
  text-align: center;
  margin-top: 1rem;
}

/* 轮播图样式 */
.carousel-section {
  padding: 6rem 10%;
  background: #f8f8f8;
}

.carousel-container {
  max-width: 1200px;
  margin: 0 auto;
}

.carousel-image-container {
  position: relative;
  height: 100%;
  width: 100%;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.carousel-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.el-carousel__item:hover .carousel-image {
  transform: scale(1.05);
}

.carousel-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  color: #fff;
  padding: 20px;
  text-align: left;
}

.carousel-caption h3 {
  margin: 0 0 10px;
  font-size: 1.5rem;
  color: #FFD700;
  font-weight: bold;
}

.carousel-caption p {
  margin: 0;
  font-size: 1rem;
}

.el-carousel__indicator {
  padding: 12px 4px;
}

.el-carousel__button {
  width: 10px;
  height: 10px;
  background-color: rgba(255, 215, 0, 0.7);
}

.el-carousel__arrow {
  background-color: rgba(139, 0, 0, 0.7);
}

.el-carousel__arrow:hover {
  background-color: rgba(139, 0, 0, 0.9);
}

/* 京剧发展历史线样式 - 横向 */
.history-timeline-section {
  padding: 6rem 10%;
  background: #fff;
}

.section-title {
  text-align: center;
  font-size: 2.8rem;
  color: #8B0000;
  margin-bottom: 4rem;
  font-family: 'STZhongsong', serif;
  position: relative;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 3px;
  background: #8B0000;
}

.timeline-horizontal {
  position: relative;
  padding: 3rem 0;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  overflow-x: auto;
}

.timeline-horizontal::before {
  content: '';
  position: absolute;
  top: 3rem;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(to right, #8B0000, #FFD700, #8B0000);
}

.timeline-item-horizontal {
  position: relative;
  min-width: 200px;
  flex: 1;
  padding: 0 10px;
  margin: 0 10px;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.6s ease;
}

.timeline-item-horizontal.animate__fadeIn {
  opacity: 1;
  transform: translateY(0);
}

.timeline-point-horizontal {
  position: absolute;
  top: -2.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 1.5rem;
  height: 1.5rem;
  background: linear-gradient(135deg, #FFD700, #FFA500);
  border-radius: 50%;
  border: 3px solid #8B0000;
  z-index: 2;
  transition: all 0.3s ease;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.timeline-item-horizontal:hover .timeline-point-horizontal {
  transform: translateX(-50%) scale(1.2);
  background: #8B0000;
  border-color: #FFD700;
}

.timeline-content-horizontal {
  position: relative;
  padding: 1.5rem;
  background: linear-gradient(145deg, #fff, #f8f8f8);
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  border: 1px solid rgba(139, 0, 0, 0.1);
  margin-top: 2rem;
  text-align: center;
}

.timeline-item-horizontal:hover .timeline-content-horizontal {
  transform: translateY(-5px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.timeline-content-horizontal h3 {
  color: #8B0000;
  margin-bottom: 0.8rem;
  font-family: 'STZhongsong', serif;
  font-size: 1.4rem;
}

.timeline-content-horizontal p {
  color: #666;
  line-height: 1.6;
}

/* 最新演出区域样式 */
.shows-section {
  padding: 6rem 10%;
  background: #fff;
}

.shows-grid {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -15px;
  max-width: 1200px;
  margin: 0 auto;
}

.show-card-col {
  margin-bottom: 30px;
  padding: 0 5px;
  width: 50%;
}

.show-card {
  transition: transform 0.3s;
  height: 100%;
}

.show-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.show-content {
  display: flex;
  height: 100%;
}

.show-poster {
  width: 40%;
  position: relative;
  height: 250px;
  overflow: hidden;
}

.show-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.show-card:hover .show-poster img {
  transform: scale(1.05);
}

.show-type {
  position: absolute;
  top: 10px;
  right: 10px;
}

.show-info {
  width: 60%;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.show-name {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 1.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.show-time, .show-address {
  margin: 8px 0;
  color: #606266;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.5;
}

.show-time i, .show-address i {
  margin-right: 5px;
}

.show-action {
  margin-top: auto;
  text-align: center;
  padding-top: 20px;
}

.show-action .el-button {
  padding: 12px 25px;
  font-size: 1.05rem;
}

@media (max-width: 992px) {
  .show-card-col {
    width: 50%;
  }
  
  .show-poster {
    height: 220px;
  }
}

@media (max-width: 768px) {
  .show-card-col {
    width: 100%;
  }
  
  .shows-grid {
    grid-template-columns: 1fr;
  }

  .announcement-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .announcement-title {
    margin-bottom: 0.5rem;
  }

  .timeline-horizontal {
    flex-direction: column;
    padding: 0;
    overflow-x: visible;
  }
  
  .timeline-horizontal::before {
    top: 0;
    left: 10px;
    width: 3px;
    height: 100%;
    background: linear-gradient(to bottom, #8B0000, #FFD700, #8B0000);
  }
  
  .timeline-item-horizontal {
    min-width: auto;
    padding: 10px 0 10px 30px;
    margin: 15px 0;
  }
  
  .timeline-point-horizontal {
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
  }
  
  .timeline-item-horizontal:hover .timeline-point-horizontal {
    transform: translateY(-50%) scale(1.2);
  }
  
  .timeline-content-horizontal {
    margin-top: 0;
    text-align: left;
  }

  .hero-section {
    height: 60vh;
  }

  .hero-content h1 {
    font-size: 3.2rem;
  }
  
  .modern-btn {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
  }
  
  .artist-card {
    animation: none;
  }
}



.confirm-button {
  padding: 0.8rem 2rem;
  background-color: #8B0000;
  color: #FFD700;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
  margin-top: 1rem;
}

.confirm-button:hover {
  background-color: #4A0404;
  transform: translateY(-2px);
}

/* 动画过渡效果 */
.fade-enter-active, .fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter, .fade-leave-to {
  opacity: 0;
}

/* 响应式设计 */
@media (max-width: 992px) {
  .hero-content h1 {
    font-size: 3rem;
  }
  
  .hero-content p {
    font-size: 1.4rem;
  }

  .section-title {
    font-size: 2.4rem;
  }
}

@media (max-width: 480px) {
  .hero-content h1 {
    font-size: 2.2rem;
  }
  
  .hero-content p {
    font-size: 1.2rem;
  }

  .section-title {
    font-size: 2rem;
  }

  .timeline-content-horizontal {
    padding: 1rem;
  }
}

/* 查看完整历史按钮美化 */
.timeline-more {
  text-align: center;
  margin-top: 4rem;
  padding-bottom: 2rem;
}

/* 更多演出按钮样式 */
.shows-more {
  text-align: center;
  margin-top: 4rem;
  padding-bottom: 2rem;
}

/* 现代简洁按钮样式 */
.modern-btn {
  display: inline-block;
  padding: 0.8rem 2.5rem;
  background-color: transparent;
  color: #8B0000;
  text-decoration: none;
  border: 2px solid #8B0000;
  border-radius: 4px;
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 1px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.modern-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 100%;
  background-color: #8B0000;
  transition: all 0.3s ease;
  z-index: -1;
}

.modern-btn:hover {
  color: #FFD700;
}

.modern-btn:hover::before {
  width: 100%;
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, #8B0000, #FFD700);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(to bottom, #660000, #FFB700);
}

/* 添加暂无演出样式 */
.no-shows {
  text-align: center;
  padding: 2rem;
  font-size: 1.2rem;
  color: #666;
}

/* 加载中样式 */
.shows-loading {
  text-align: center;
  padding: 2rem;
  font-size: 1.2rem;
  color: #666;
}

.skeleton-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.skeleton-card {
  width: 300px;
  height: 300px;
  background-color: #f0f0f0;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.skeleton-image {
  width: 100%;
  height: 100%;
  background-color: #e0e0e0;
}

.skeleton-content {
  padding: 20px;
}

.skeleton-title {
  width: 100%;
  height: 20px;
  background-color: #e0e0e0;
  margin-bottom: 10px;
}

.skeleton-text {
  width: 100%;
  height: 16px;
  background-color: #e0e0e0;
  margin-bottom: 8px;
}

.skeleton-button {
  width: 100px;
  height: 40px;
  background-color: #e0e0e0;
  border-radius: 5px;
  margin-top: 10px;
}

/* 公告详情对话框样式 */
.el-dialog__wrapper {
  backdrop-filter: blur(5px);
}

.el-dialog {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.el-dialog__header {
  background-color: #8B0000;
  color: white;
  padding: 15px 20px;
}

.el-dialog__title {
  color: #FFD700;
  font-weight: bold;
  font-size: 1.2rem;
  font-family: 'STZhongsong', serif;
}

.el-dialog__headerbtn .el-dialog__close {
  color: rgba(255, 255, 255, 0.8);
}

.el-dialog__headerbtn:hover .el-dialog__close {
  color: #FFD700;
}

.announcement-dialog-content {
  padding: 20px;
  background-color: #fff;
  border-radius: 0 0 10px 10px;
}

.announcement-dialog-date {
  color: #909399;
  font-size: 0.9rem;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
}

.announcement-dialog-date i {
  margin-right: 5px;
  color: #8B0000;
}

.announcement-dialog-body {
  line-height: 1.8;
  white-space: pre-line;
  color: #303133;
  font-size: 1.1rem;
  margin-bottom: 20px;
  padding: 15px;
  background-color: #f9f9f9;
  border-radius: 8px;
}

/* 添加公告图片预览样式 */
.announcement-dialog-image {
  margin: 15px 0;
  text-align: center;
}

.announcement-dialog-image .el-image {
  max-width: 100%;
  max-height: 400px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.3s ease;
}

.announcement-dialog-image .el-image:hover {
  transform: scale(1.02);
}

/* 添加加载动画样式 */
.announcement-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
}

.announcement-loading-spinner {
  font-size: 2rem;
  color: #8B0000;
  margin-bottom: 15px;
}

.announcement-loading-text {
  color: #909399;
  font-size: 1rem;
}

/* 骨架屏脉动动画 */
@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

.skeleton-title, .skeleton-text, .skeleton-date, .skeleton-button, .skeleton-image, .skeleton-icon {
  animation: pulse 1.5s infinite ease-in-out;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: pulse-bg 1.5s infinite;
}

@keyframes pulse-bg {
  0% { background-position: 0% 0; }
  100% { background-position: -200% 0; }
}

/* 模块选择对话框样式 */
.module-selection-dialog >>> .el-dialog__header {
  background-color: #8B0000;
  padding: 15px 20px;
}

.module-selection-dialog >>> .el-dialog__title {
  color: #FFD700;
  font-size: 1.3rem;
  font-family: 'STZhongsong', serif;
}

.module-selection-tip {
  text-align: center;
  margin-bottom: 20px;
  color: #606266;
  font-size: 1rem;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 5px;
}

.module-item {
  padding: 15px;
  border-radius: 6px;
  transition: all 0.2s ease;
  border: 1px solid #EBEEF5;
  cursor: pointer;
  background-color: #fff;
}

.module-item:hover {
  background-color: #f5f7fa;
  transform: translateY(-2px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  border-color: #dcdfe6;
}

.module-content {
  display: flex;
  align-items: flex-start;
}

.module-icon {
  font-size: 2rem;
  margin-right: 12px;
  margin-top: 2px;
}

.module-info {
  flex: 1;
}

.module-title {
  font-size: 1.1rem;
  color: #303133;
  margin-bottom: 5px;
  font-weight: 500;
}

.module-description {
  font-size: 0.85rem;
  color: #606266;
  line-height: 1.4;
}

@media (max-width: 992px) {
  .module-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .module-grid {
    grid-template-columns: 1fr;
  }
}
</style> 